package ar.edu.unq.wannaplay.utils;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;

import ar.edu.unq.wannaplay.dtos.ClientDTO;
import ar.edu.unq.wannaplay.services.ClientService;

public class ClientListView extends WPItemListView<ClientDTO, ClientService> {

    private static final long serialVersionUID = 1L;

    public ClientListView(final String id, final ClientService aService, final List<String> labels, final Panel panel) {
        super(id, aService, labels, aService.findAllDTOs(), panel);
        this.setList(aService.findAllDTOs());
    }

    @Override
    protected void addLinks(final ListItem<ClientDTO> item) {
        this.getUser().addClientViewLinks(item, this, this.getPanel());
    }

    @Override
    protected void populateItem(final ListItem<ClientDTO> item) {
        ClientDTO client = (ClientDTO) item.getDefaultModelObject();
        item.add(new Label("name", new PropertyModel<ClientDTO>(client, "name")));
        item.add(new Label("email", new PropertyModel<ClientDTO>(client, "email")));
        this.addLinks(item);
    }

}
